package com.wzl.common.exception;

import com.wzl.common.errcode.VkErrorCode;

/**
 * 异常
 *
 * @author wzl
 * @since 2022-08-27 15:40
 */
public class VkPublicException extends Exception {

    private static final long serialVersionUID = -6877633364576501597L;

    private String errCode;
    private String errMsg;

    public VkPublicException() {
        super();
    }

    public VkPublicException(String message, Throwable cause) {
        super(message, cause);
    }

    public VkPublicException(String message) {
        super(message);
    }

    public VkPublicException(Throwable cause) {
        super(cause);
    }

    public VkPublicException(String errCode, String errMsg) {
        super(errMsg);
        this.errCode = errCode;
        this.errMsg = errMsg;
    }

    public VkPublicException(VkErrorCode errorCodeEnum) {
        super(errorCodeEnum.getMessage());
        this.errCode = errorCodeEnum.getCode();
        this.errMsg = errorCodeEnum.getMessage();
    }

    public VkPublicException(VkErrorCode errorCodeEnum, String... args) {
        super(errorCodeEnum.getMessage());
        this.errCode = errorCodeEnum.getCode();
        StringBuilder argsStringBuffer = new StringBuilder(",[");
        for (String arg : args) {
            argsStringBuffer.append(arg == null ? "null" : arg);
        }
        argsStringBuffer.append("]");
        this.errMsg = errorCodeEnum.getMessage() + argsStringBuffer;
    }

    public VkPublicException(VkErrorCode errorCodeEnum, Throwable cause) {
        super(cause);
        this.errCode = errorCodeEnum.getCode();
        this.errMsg = errorCodeEnum.getMessage();
    }

    public VkPublicException(String errCode, String errMsg, Throwable cause) {
        super(cause);
        this.errCode = errCode;
        this.errMsg = errMsg;
    }

    public String getErrCode() {
        return this.errCode;
    }

    public String getErrMsg() {
        return this.errMsg;
    }
}
